{% if json_output %}
{% for key in json_output %}
    {# This condition checks if the JSON response has data from the acl/interface list #}
    {% if "interface" in key %}
        {% for interface in json_output[key] %}
           {% set if_id = interface["id"] %}
           {% if interface["ingress-acl-sets"] %}
                {% set idirection = "ingress" %}
           {% endif %}
           {% if interface["egress-acl-sets"] %}
               {% set edirection = "egress" %}
           {% endif %}
           {% if idirection %}
               {% set ing_acl_sets = idirection + "-acl-sets" %}
               {% set ing_acl_set = idirection + "-acl-set" %}
               {% set ing_acl_set_list = interface[ing_acl_sets][ing_acl_set] %}
               {% for ing_acl_set in ing_acl_set_list %}
                   {% set i_acl_name = ing_acl_set["set-name"] %}
                   {% if idirection == "ingress" %}
                       {% set idirection = "Ingress" %}
                   {% endif %}
                   {{- idirection }} IP access-list {{ i_acl_name }} on {{ if_id }}
               {% endfor %}
           {% endif %}
           {% if edirection %}
               {% set eg_acl_sets = edirection + "-acl-sets" %}
               {% set eg_acl_set = edirection + "-acl-set" %}
               {% set eg_acl_set_list = interface[eg_acl_sets][eg_acl_set] %}
               {% for eg_acl_set in eg_acl_set_list %}
                   {% set e_acl_name = eg_acl_set["set-name"] %}
                   {% if edirection == "egress" %}
                       {% set edirection = "Egress" %}
                   {% endif %}
                   {{- edirection }} IP access-list {{ e_acl_name }} on {{ if_id }}
               {% endfor %}
           {% endif %}
        {% endfor %}
    {% endif %}
{% endfor %}
{% endif %}
